package com.example.security.handle;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @application:
 * @author: LiYuhang
 * @Date: 2021/5/29 20:46
 * @version: 0.1
 * @Description :
 * @Modified By:
 */
public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request,HttpServletResponse res,AuthenticationException authException) throws IOException, ServletException {
       ResponseMsg.response(res,map->{
           map.put("code",HttpStatus.FORBIDDEN.value());
           map.put("msg","未登录");
       });
    }
}
